package com.cybertron.ironhide.manage.action;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import com.cybertron.ironhide.manage.common.base.BaseAction;
import com.cybertron.ironhide.manage.domain.Recommend;
import com.cybertron.ironhide.manage.service.RecommendService;

public class RecommendAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1114834215789668284L;

	@Resource
	private RecommendService recommendService;

	private Recommend recommend;

	private List<Recommend> recommends;

	private File file;

	private String fileFileName;

	public String list() {
		recommends = recommendService.selectBySelective(recommend, pager);
		return LIST;
	}

	public String add() {
		return ADD;
	}

	public String doAdd() throws IOException {
		recommend.setCreateDate(new Date());
		recommendService.insertSelective(recommend);
		return ajaxSuccess("推荐添加成功", "index-list", "index-list-box",
				CLOSE_CURRENT);
	}

	public String edit() {
		recommend = recommendService.selectByPrimaryKey(recommend.getId());
		return EDIT;
	}

	public String doEdit() throws IOException {
		recommend.setModifyDate(new Date());
		recommendService.updateByPrimaryKeySelective(recommend);
		return ajaxSuccess("推荐编辑成功", "index-list", "index-list-box",
				CLOSE_CURRENT);
	}

	public String delete() {
		recommendService.deleteByPrimaryKey(recommend.getId());
		return ajaxSuccess("推荐删除成功", "index-list", "index-list-box");
	}

	public RecommendService getRecommendService() {
		return recommendService;
	}

	public void setRecommendService(RecommendService recommendService) {
		this.recommendService = recommendService;
	}

	public Recommend getRecommend() {
		return recommend;
	}

	public void setRecommend(Recommend recommend) {
		this.recommend = recommend;
	}

	public List<Recommend> getRecommends() {
		return recommends;
	}

	public void setRecommends(List<Recommend> recommends) {
		this.recommends = recommends;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public String getFileFileName() {
		return fileFileName;
	}

	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}

}
